package com.nbst.service.base.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.nbst.comnutil.NormalResult;
import com.nbst.comnutil.StringUtil;
import com.nbst.dao.mapper.mes.ButtonMapper;
import com.nbst.model.base.Button;
import com.nbst.service.base.IButtonService;

/**
 * @ClassName: ButtonServiceImpl
 * @Description:
 * @author King
 * @date 2018年11月7日
 * 
 */
@Service
public class ButtonServiceImpl extends BaseServiceImpl<Button, ButtonMapper> implements IButtonService {

	@Override
	public NormalResult findByCondition(Map<String,Object> map, Integer offset, Integer row){
		return super.findByCondition(map, offset, row);
	}

	@Override
	public NormalResult insertSelective(Button t) {
		
		return super.insertSelective(t);
	}

	@Override
	public NormalResult updateByPrimaryKeySelective(Button t) {
		// TODO 自动生成的方法存根
		return super.updateByPrimaryKeySelective(t);
	}

	@Override
	public NormalResult deleteByPrimaryKey(Object t) {
		// TODO 自动生成的方法存根
		return super.deleteByPrimaryKey(t);
	}

	@Override
	@Transactional
	public NormalResult addNewButtonAddRole(Integer fRid, String fBids) {
		NormalResult result = new NormalResult();
		if(fRid==null) {
			result.setMessage("角色id不能为空");
		}
		String [] ids =null;
		if(!StringUtil.isEmpty(fBids)) {
			ids = fBids.split(",");
		}
		try {
			super.getMapper().deleteByRid(fRid);
			if(ids!=null) {
				if(ids.length>0) {
					List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
					for(int i = 0;i<ids.length;i++) {
						Map<String,Object> map = new HashMap<>(8);
						map.put("fRid", fRid);
						map.put("fBid", Integer.valueOf(ids[i]));
						
					}
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		
		return null;
	}

}
